import axios from "axios";
import cookies from "./cookies";
const service = axios.create({
  // 设置请求地址
  baseURL: "http://124.221.119.213:3000/",
  // baseURL: "http://localhost:3000",

  // 设置超时时间
  withCredentials: true,
});

service.interceptors.request.use(
  (config) => {
    // config.url请求地址
    // config.code请求状态
    if (config.method == "get" && config.params != undefined) {
      config.params.timestamp = new Date().getTime();
    }
    return config;
  },
  (error) => {
    // 返回错误信息
    return config;
  }
);

service.interceptors.response.use(
  (response) => {
    // 请求成功返回的数据
    return response.data;
  },
  (error) => {
    return error.response.data;
  }
);
export default service;
